package sc.writable;

import org.apache.hadoop.io.FloatWritable;

/**
 * Writtable Array for float types
 * 
 * @author Quentin Rossé
 *
 */
public class WritableArrayListFloat extends WritableArrayList<FloatWritable>{
	
	public WritableArrayListFloat(){
		super(FloatWritable.class);
	}
	
	/**
	 * return the float value at the i th position in the array 
	 * @param i
	 * @return
	 */
	public float getFloat(int i){
		return super.get(i).get();
	}
	
	public void add(float f){
		super.add(new FloatWritable(f));
	}
	

	public void add(float f, int maxsize){
		super.add(new FloatWritable(f), maxsize);
	}

	public float[] toFloatArray(){
		float[] tab = new float[super.size()];
		for(int i=0; i<tab.length; i++)
			tab[i] = super.get(i).get();
		return tab;
	}
}
